﻿using System;
using System.Collections.Generic;
using System.Text;
using Entity;

namespace AutoGear.BLL
{
   public class FreeRestringingForm
    {

         #region FreeRestringingForm Private Fields

        Int32 _formId;
		DateTime _formDate;
		String _userName = String.Empty;
		String _userAddress = String.Empty;
		String _userTelephoneNumber = String.Empty;
		String _userEmailAddress = String.Empty;
		String _lengthOfNecklace = String.Empty;
		String _totalPearls = String.Empty;
		String _sizeOfPearls = String.Empty;
		Boolean _isKnotted;
		String _comments = String.Empty;
		DateTime _createDate;

        #endregion

        #region FreeRestringingForm Constractor
		/// <summary>
        /// Creates an empty object of TblFreeRestringingForm. 
        /// This is mainly used to create a new instance of TblFreeRestringingForm to add a new TblFreeRestringingForm.
        /// </summary>
		public FreeRestringingForm(){}
		
				
		/// <summary>
        /// Used to retrieve employee information from database, 
        /// which is also used by Update method to save information of an existing TblFreeRestringingForm.
        /// </summary>
        public FreeRestringingForm
		(
			Int32 formId,
			DateTime formDate,
			String userName,
			String userAddress,
			String userTelephoneNumber,
			String userEmailAddress,
			String lengthOfNecklace,
			String totalPearls,
			String sizeOfPearls,
			Boolean isKnotted,
			String comments,
			DateTime createDate
		)
		{
			_formId = formId;	
			_formDate = formDate;	
			_userName = userName;	
			_userAddress = userAddress;	
			_userTelephoneNumber = userTelephoneNumber;	
			_userEmailAddress = userEmailAddress;	
			_lengthOfNecklace = lengthOfNecklace;	
			_totalPearls = totalPearls;	
			_sizeOfPearls = sizeOfPearls;	
			_isKnotted = isKnotted;	
			_comments = comments;	
			_createDate = createDate;	
		}
		
		#endregion
		#region FreeRestringingForm Properties
		
		 /***********************************************************************************************
                                    -- PROPERTIES --        
         Contains all the properties representing the data fields of the current entity.
         ***********************************************************************************************/

        /// <summary>
        /// This is the Primary key value of the FormId, which can't be assigned from the application,
        /// to ensure the data consistancy, by not letting the user to change the PK_TblFreeRestringingForm to update the data of an another TblFreeRestringingForm instance.
        /// For view or updation purpose, every TblFreeRestringingForm will be retrieved thru the proper 'Get' method.
        /// </summary>
		
		public Int32 FormId
		{
			get {return _formId;}	
		}
		
				
		public DateTime FormDate
		{
			get {return _formDate;}
			set {_formDate = value;}
		}

		public String UserName
		{
			get {return _userName;}
			set {_userName = value;}
		}

		public String UserAddress
		{
			get {return _userAddress;}
			set {_userAddress = value;}
		}

		public String UserTelephoneNumber
		{
			get {return _userTelephoneNumber;}
			set {_userTelephoneNumber = value;}
		}

		public String UserEmailAddress
		{
			get {return _userEmailAddress;}
			set {_userEmailAddress = value;}
		}

		public String LengthOfNecklace
		{
			get {return _lengthOfNecklace;}
			set {_lengthOfNecklace = value;}
		}

		public String TotalPearls
		{
			get {return _totalPearls;}
			set {_totalPearls = value;}
		}

		public String SizeOfPearls
		{
			get {return _sizeOfPearls;}
			set {_sizeOfPearls = value;}
		}

		public Boolean IsKnotted
		{
			get {return _isKnotted;}
			set {_isKnotted = value;}
		}

		public String Comments
		{
			get {return _comments;}
			set {_comments = value;}
		}

		public DateTime CreateDate
		{
			get {return _createDate;}
			set {_createDate = value;}
		}
		

		#endregion

        public void Create()
        {

            try
            {
                this._formId = TblFreeRestringingForm.CreateNewTblFreeRestringingForm(FormDate, UserName, UserAddress, UserTelephoneNumber, UserEmailAddress, LengthOfNecklace,TotalPearls, SizeOfPearls, IsKnotted,Comments,CreateDate);
            }
            catch (Exception e)
            {
                throw e;
            }
        }

        public bool Update()
        {
            try
            {
                TblFreeRestringingForm tblFreeRestringingForm = TblFreeRestringingForm.GetTblFreeRestringingFormByFormId(this._formId);
                tblFreeRestringingForm.FormDate = this._formDate;
                tblFreeRestringingForm.UserName = this._userName;
                tblFreeRestringingForm.UserAddress = this._userAddress;
                tblFreeRestringingForm.UserTelephoneNumber = this._userTelephoneNumber;
                tblFreeRestringingForm.UserEmailAddress = this._userEmailAddress;
                tblFreeRestringingForm.LengthOfNecklace = this._lengthOfNecklace;
                tblFreeRestringingForm.TotalPearls = this._totalPearls;
                tblFreeRestringingForm.SizeOfPearls = this._sizeOfPearls;
                tblFreeRestringingForm.IsKnotted = this._isKnotted;
                tblFreeRestringingForm.Comments = this._comments;
                tblFreeRestringingForm.CreateDate = this._createDate;
                return tblFreeRestringingForm.Save();
            }
            catch (Exception e)
            {
                throw e;
            }
        }

        public void Delete()
        {
            throw new Exception("Method not implemented");
        }



        public static FreeRestringingForm Load(int formId)
        {
            try
            {
                TblFreeRestringingForm tblFreeRestringingForm = TblFreeRestringingForm.GetTblFreeRestringingFormByFormId(formId);
                FreeRestringingForm freeRestringingForm = new FreeRestringingForm(tblFreeRestringingForm.FormId, tblFreeRestringingForm.FormDate, tblFreeRestringingForm.UserName, tblFreeRestringingForm.UserAddress, tblFreeRestringingForm.UserTelephoneNumber, tblFreeRestringingForm.UserEmailAddress, tblFreeRestringingForm.LengthOfNecklace, tblFreeRestringingForm.TotalPearls, tblFreeRestringingForm.SizeOfPearls, tblFreeRestringingForm.IsKnotted, tblFreeRestringingForm.Comments, tblFreeRestringingForm.CreateDate);
                return freeRestringingForm;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
    }
}
